<?php

/*
 * @copyright :     Ienter asia Technologies
 * @author :        Hunglv
 * @version         v.1.0
 * @created         11/6/2014
 * @Description :   Class model Time Card
 */
if (!defined('BASEPATH'))
    exit('No direct script access allowed');
class Mmod_timecard extends MYAD_Model{
    protected $table_name = 'timecard';
    protected $table_leaveregistration = 'm_leaveregistration';
    protected $table_shiftinfo = 'shiftinfo';
    function __construct() {
        parent::__construct();
        $this->load->model('mod_tcmanipulation/Mmod_tcmanipulation');
    }
    function listTimeCardByEmployeeMonthYear($employeeId,$month,$year){
        $this->db->from($this->table_name.' as a ');
        $this->db->join($this->table_shiftinfo.' as b ', 'b.ShiftId = a.ShiftId');
        $this->db->where('a.EmployeeId',$employeeId);
        $this->db->where('MONTH(a.Date) = '.$month);
        $this->db->where('YEAR(a.Date) = '.$year);
        $this->db->order_by("Date", "ASC");
        $query = $this->db->get();
        return $query->result_array();
    }
        /*
         * @author :        HungLV
         * @created:        
         * @Description:   Caculation time working holiday one day of employee
         * @Input :        variable
         * @Output :       Return array data time working holiday
         */      
    function timeCardWorkingHoliDay($Arrivaltime,$Leavetime,$Date,$employeeID,$shiftInfo){
            // Trimmed Arrival Time
            $Arrivaltime = $Arrivaltime;
            // Leave Time
            $Leavetime = $Leavetime;
            
            $registrationDates = $this->Mmod_tcmanipulation->getLeaveRegistrationEmployeeID($employeeID,$Date);
            // code for holiday
            // if $Leavetime != empty
            if($Leavetime!=""){
                // check $Leavetime > $Arrivaltime
                if( strtotime($Leavetime) > strtotime($Arrivaltime) ){
                    // check overtime 
                    if($this->Mmod_tcmanipulation->isCheckOvertime($employeeID,$Date))
                    {
                        // caculation late over time
                        $HolidayLateOvertime00 = $this->Mmod_tcmanipulation->weekdayLateOvertime($Arrivaltime,$Leavetime,$shiftInfo['StartNightOvertime']);
                        // caculation overtime
                        $HolidayLateOvertime01 = $this->Mmod_tcmanipulation->weekdayOvertime($Arrivaltime,$Leavetime,$shiftInfo['EndEveningOvertime'],$shiftInfo['StartEveningOvertime']);
                        // caculation working nomarl time
                        $HolidayOvertime02 = $this->Mmod_tcmanipulation->weekdayNormalTime($Arrivaltime,$Leavetime,$shiftInfo['EndTime'],$shiftInfo['StartTime'],$shiftInfo['EndRestTime1'],$shiftInfo['StartRestTime1']);
                        if(isset($registrationDates)&& !empty($registrationDates)){
                            foreach($registrationDates as $registrationDate){
                                // case 1 leave registration is Paid
                                if($this->Mmod_tcmanipulation->isCheckLeaveRegistrationPaid($registrationDate['LeaveTypeId'],$employeeID,$Date)== false){
                                    // caculation resetime 30
                                    $Restime30 = $this->Mmod_tcmanipulation->resTime30($Arrivaltime,$Leavetime,$shiftInfo['StartNightOvertime'],$shiftInfo['EndNightOvertime'],$registrationDate['StartTime'],$registrationDate['EndTime']);
                                    // caculation resetime 20
                                    $Restime20 = $this->Mmod_tcmanipulation->resTime20($Arrivaltime,$Leavetime,$shiftInfo['StartEveningOvertime'],$shiftInfo['EndEveningOvertime'],$registrationDate['StartTime'],$registrationDate['EndTime']);
                                    // caculation resetime 10
                                    $Restime10 = $this->Mmod_tcmanipulation->resTime10($Arrivaltime,$Leavetime,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1'],$shiftInfo['StartTime'],$shiftInfo['EndTime'],$registrationDate['StartTime'],$registrationDate['EndTime']);                                                            
                                }
                                else{
                                    $LeaveTime = 1;
                                }
                            }                                                     
                        }
                        else{
                            $Restime30 = 0;
                            $Restime20 = 0;
                            $Restime10 = 0;
                        }
                        // caculation resetime 3 default
                        $Restime31 = $this->Mmod_tcmanipulation->resTime31($Arrivaltime,$Leavetime,$shiftInfo['EndEveningOvertime'],$shiftInfo['StartNightOvertime']);
                        // caculation resetime 2 default
                        $Restime21 = $this->Mmod_tcmanipulation->resTime21($Arrivaltime,$Leavetime,$shiftInfo['EndTime'],$shiftInfo['StartEveningOvertime']);
                        // caculation resetime 1 default
                        $Restime11 = $this->Mmod_tcmanipulation->resTime11($Arrivaltime,$Leavetime,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1']);

                        // caculation $HolidayLateOvertime
                        $HolidayLateOvertime = $HolidayLateOvertime00 - $Restime30;
                        $HolidayLateOvertime = $HolidayLateOvertime + ($HolidayLateOvertime01 - $Restime20);
                        // caculation $HolidayOvertime
                        $HolidayOvertime = $HolidayOvertime02 - $Restime10;
                        // caculation WeekdayLateOvertime
                        $WeekdayLateOvertime = 0;
                        // caculation WeekdayOvertime
                        $WeekdayOvertime = 0;
                        // caculation $WeekdayNormalTime
                        $WeekdayNormalTime = 0;                                                
                        // WeekendOvertime
                        $WeekendOvertime = 0;
                        // WeekendLateOvertime
                        $WeekendLateOvertime = 0;                                                                                                                                               
                        // Restime 1
                        $ResTime1 = $Restime11 + $Restime10;     
                        // Restime 2
                        $ResTime2 = $Restime21 + $Restime20; 
                        // Restime 3
                        $ResTime3 = $Restime31 + $Restime30;                        
                        // Actual WorkHours
                        $ActualWorkHours = $WeekdayNormalTime + $WeekdayOvertime + $WeekdayLateOvertime + $WeekendOvertime + $WeekendLateOvertime + $HolidayOvertime + $HolidayLateOvertime;

                    }
                    else{
                        $addWorkNormalTime = 0;
                        // caculation working nomarl day time
                        $HolidayOvertime02 = $this->Mmod_tcmanipulation->weekdayNormalTime($Arrivaltime,$Leavetime,$shiftInfo['EndTime'],$shiftInfo['StartTime'],$shiftInfo['EndRestTime1'],$shiftInfo['StartRestTime1']); 
                        // caculation resetime 1 default
                        $Restime11 = $this->Mmod_tcmanipulation->resTime11($Arrivaltime,$Leavetime,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1']);
                        if(isset($registrationDates)&& !empty($registrationDates)){
                            foreach($registrationDates as $registrationDate){
                                // case 1 leave registration is Paid
                                $addWorkNormalTime = $this->Mmod_tcmanipulation->getTimeLeaveRegistrationIsPaid($Arrivaltime,$Leavetime,$registrationDates,$shiftInfo['TotalWorkHours'],$shiftInfo['StartTimeAfternoon'],$employeeID,$Date,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1'],$shiftInfo['EndTime']);
                                if($this->Mmod_tcmanipulation->isCheckLeaveRegistrationPaid($registrationDate['LeaveTypeId'],$employeeID,$arrTime[$rowdata][$Coldate])== false){
                                    // caculation resetime 10
                                    $Restime10 = $this->Mmod_tcmanipulation->resTime10($Arrivaltime,$Leavetime,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1'],$shiftInfo['StartTime'],$shiftInfo['EndTime'],$registrationDate['StartTime'],$registrationDate['EndTime']);                                                            
                                }
                             }                                                    
                        }
                        else{
                            $Restime10 = 0;
                        }                                                
                        // caculation WeekdayLateOvertime
                        $WeekdayLateOvertime = 0;
                        // caculation WeekdayOvertime
                        $WeekdayOvertime = 0;
                        // caculation $WeekdayNormalTime
                        $WeekdayNormalTime = ($HolidayOvertime02 - $Restime10) +  $addWorkNormalTime['addtime'] + $addWorkNormalTime['downtime'];
                        // WeekendOvertime
                        $WeekendOvertime = 0;
                        // WeekendLateOvertime
                        $WeekendLateOvertime = 0;
                        // HolidayOvertime
                        $HolidayOvertime = 0;
                        // HolidayLateOvertime
                        $HolidayLateOvertime = 0;                                                                                                                                                
                        // Restime 1
                        $ResTime1 = $Restime11 + $Restime10;     
                        // Restime 2
                        $ResTime2 = 0; 
                        // Restime 3
                        $ResTime3 = 0;                       
                        // Actual WorkHours
                        $ActualWorkHours = ($HolidayOvertime02 - $Restime10 + $addWorkNormalTime['downtime']) + $WeekdayOvertime + $WeekdayLateOvertime + $WeekendOvertime + $WeekendLateOvertime + $HolidayOvertime + $HolidayLateOvertime ;

                    }
                }
                else{
                        // caculation WeekdayLateOvertime
                        $WeekdayLateOvertime = 0;
                        // caculation WeekdayOvertime
                        $WeekdayOvertime = 0;
                        // caculation $WeekdayNormalTime
                        $WeekdayNormalTime = 0;
                        // WeekendOvertime
                        $WeekendOvertime = 0;
                        // WeekendLateOvertime
                        $WeekendLateOvertime = 0;
                        // HolidayOvertime
                        $HolidayOvertime = 0;
                        // HolidayLateOvertime
                        $HolidayLateOvertime = 0;                                                                                                                                                
                        // Restime 1
                        $ResTime1 = 0;     
                        // Restime 2
                        $ResTime2 = 0; 
                        // Restime 3
                        $ResTime3 = 0;                        
                        // Actual WorkHours
                        $ActualWorkHours = 0;
                }
            }
            // arrivaltime is empty
            else{
                /* no caculation time working */
                // caculation WeekdayLateOvertime
                $WeekdayLateOvertime = 0;
                // caculation WeekdayOvertime
                $WeekdayOvertime = 0;
                // caculation $WeekdayNormalTime
                $WeekdayNormalTime = 0;
                // WeekendOvertime
                $WeekendOvertime = 0;
                // WeekendLateOvertime
                $WeekendLateOvertime = 0;
                // HolidayOvertime
                $HolidayOvertime = 0;
                // HolidayLateOvertime
                $HolidayLateOvertime = 0;                                                                                                                                                
                // Restime 1
                $ResTime1 = 0;     
                // Restime 2
                $ResTime2 = 0; 
                // Restime 3
                $ResTime3 = 0;
                // Actual WorkHours
                $ActualWorkHours = 0;										
            }
            $data = array(
                'ResTime1'                  =>  $ResTime1,
                'ResTime2'                  =>  $ResTime2,
                'ResTime3'                  =>  $ResTime3,
                'WeekdayNormalTime'         =>  $WeekdayNormalTime,
                'WeekdayOvertime'           =>  $WeekdayOvertime,
                'WeekdayLateOvertime'       =>  $WeekdayLateOvertime,
                'WeekendOvertime'           =>  $WeekendOvertime,
                'WeekendLateOvertime'       =>  $WeekendLateOvertime,
                'HolidayOvertime'           =>  $HolidayOvertime,
                'HolidayLateOvertime'       =>  $HolidayLateOvertime,
                'ActualWorkHours'           =>  $ActualWorkHours,                                                                                                                              
            );
            return $data;
        }
        /*
         * @author :        HungLV
         * @created:        
         * @Description:   Caculation time working normal one day of employee
         * @Input :        variable
         * @Output :       Return array data time working normal
         */        
        function timeCardWorkingNormalDay($Arrivaltime,$Leavetime,$Date,$employeeID,$shiftInfo){
            
            $registrationDates = $this->Mmod_tcmanipulation->getLeaveRegistrationEmployeeID($employeeID,$Date);
            
            $Restime30 = 0;
            $Restime20 = 0;
            $Restime10 = 0;        
        // code for normal day
        // caculation time working day
            // if $Leavetime != empty
            if($Leavetime!=""){
                // check $Leavetime > $Arrivaltime
                if( strtotime($Leavetime) > strtotime($Arrivaltime) ){
                    // check overtime 
                    if($this->Mmod_tcmanipulation->isCheckOvertime($employeeID,$Date))
                    {
                        $addWorkNormalTime = 0;
                        // caculation late over time
                        $WeekdayLateOvertime00 = $this->Mmod_tcmanipulation->weekdayLateOvertime($Arrivaltime,$Leavetime,$shiftInfo['StartNightOvertime']);
                        // caculation overtime
                        $WeekdayOvertime01 = $this->Mmod_tcmanipulation->weekdayOvertime($Arrivaltime,$Leavetime,$shiftInfo['EndEveningOvertime'],$shiftInfo['StartEveningOvertime']);
                        // caculation working nomarl time
                        $WeekdayNormalTime02 = $this->Mmod_tcmanipulation->weekdayNormalTime($Arrivaltime,$Leavetime,$shiftInfo['EndTime'],$shiftInfo['StartTime'],$shiftInfo['EndRestTime1'],$shiftInfo['StartRestTime1']);
                        if(isset($registrationDates)&& !empty($registrationDates)){
                            foreach($registrationDates as $registrationDate){
                                // case 1 leave registration is Paid
                                $addWorkNormalTime = $this->Mmod_tcmanipulation->getTimeLeaveRegistrationIsPaid($Arrivaltime,$Leavetime,$registrationDates,$shiftInfo['TotalWorkHours'],$shiftInfo['StartTimeAfternoon'],$employeeID,$Date,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1'],$shiftInfo['EndTime']);
                                if($this->Mmod_tcmanipulation->isCheckLeaveRegistrationPaid($registrationDate['LeaveTypeId'],$employeeID,$Date)== false){
                                // case 2 leave registration un Paid
                                    // caculation resetime 30
                                    $Restime30 = $Restime30 + $this->Mmod_tcmanipulation->resTime30($Arrivaltime,$Leavetime,$shiftInfo['StartNightOvertime'],$shiftInfo['EndNightOvertime'],$registrationDate['StartTime'],$registrationDate['EndTime']);
                                    // caculation resetime 20
                                    $Restime20 = $Restime20 + $this->Mmod_tcmanipulation->resTime20($Arrivaltime,$Leavetime,$shiftInfo['StartEveningOvertime'],$shiftInfo['EndEveningOvertime'],$registrationDate['StartTime'],$registrationDate['EndTime']);
                                    // caculation resetime 10
                                    $Restime10 = $Restime10 + $this->Mmod_tcmanipulation->resTime10($Arrivaltime,$Leavetime,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1'],$shiftInfo['StartTime'],$shiftInfo['EndTime'],$registrationDate['StartTime'],$registrationDate['EndTime']);                                                        
                                }
                            }                                                
                        }
                        else{
                            $Restime30 = 0;
                            $Restime20 = 0;
                            $Restime10 = 0;
                        }
                        // caculation resetime 3 default
                        $Restime31 = $this->Mmod_tcmanipulation->resTime31($Arrivaltime,$Leavetime,$shiftInfo['EndEveningOvertime'],$shiftInfo['StartNightOvertime']);
                        // caculation resetime 2 default
                        $Restime21 = $this->Mmod_tcmanipulation->resTime21($Arrivaltime,$Leavetime,$shiftInfo['EndTime'],$shiftInfo['StartEveningOvertime']);
                        // caculation resetime 1 default
                        $Restime11 = $this->Mmod_tcmanipulation->resTime11($Arrivaltime,$Leavetime,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1']);
                        // caculation WeekdayLateOvertime
                        $WeekdayLateOvertime = $WeekdayLateOvertime00 - $Restime30;
                        // caculation WeekdayOvertime
                        $WeekdayOvertime = $WeekdayOvertime01 - $Restime20;
                        // caculation $WeekdayNormalTime
                        $WeekdayNormalTime = ($WeekdayNormalTime02 - $Restime10) + $addWorkNormalTime['addtime']+$addWorkNormalTime['downtime'];
                        // WeekendOvertime
                        $WeekendOvertime = 0;
                        // WeekendLateOvertime
                        $WeekendLateOvertime = 0;
                        // HolidayOvertime
                        $HolidayOvertime = 0;
                        // HolidayLateOvertime
                        $HolidayLateOvertime = 0;                                                                                                                                                
                        // Restime 1
                        $ResTime1 = $Restime11 + $Restime10;     
                        // Restime 2
                        $ResTime2 = $Restime21 + $Restime20; 
                        // Restime 3
                        $ResTime3 = $Restime31 + $Restime30; 
                        // Actual Work Hours
                        $ActualWorkHours = ($WeekdayNormalTime02 - $Restime10 + $addWorkNormalTime['downtime']) + $WeekdayOvertime + $WeekdayLateOvertime + $WeekendOvertime + $WeekendLateOvertime + $HolidayOvertime + $HolidayLateOvertime;
                    }
                    else{
                        $addWorkNormalTime = 0;
                        // caculation working nomarl time
                        $WeekdayNormalTime02 = $this->Mmod_tcmanipulation->weekdayNormalTime($Arrivaltime,$Leavetime,$shiftInfo['EndTime'],$shiftInfo['StartTime'],$shiftInfo['EndRestTime1'],$shiftInfo['StartRestTime1']); 
                        // caculation resetime 1 default
                        $Restime11 = $this->Mmod_tcmanipulation->resTime11($Arrivaltime,$Leavetime,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1']);
                        if(isset($registrationDates)&& !empty($registrationDates)){
                            // caculation leave registration is Paid
                            $addWorkNormalTime = $this->Mmod_tcmanipulation->getTimeLeaveRegistrationIsPaid($Arrivaltime,$Leavetime,$registrationDates,$shiftInfo['TotalWorkHours'],$shiftInfo['StartTimeAfternoon'],$employeeID,$Date,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1'],$shiftInfo['EndTime']);
                            foreach($registrationDates as $registrationDate){
                                // leave registration un Paid
                                if($this->Mmod_tcmanipulation->isCheckLeaveRegistrationPaid($registrationDate['LeaveTypeId'],$employeeID,$Date)== false){
                                    // caculation resetime 10
                                    $Restime10 = $this->Mmod_tcmanipulation->resTime10($Arrivaltime,$Leavetime,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1'],$shiftInfo['StartTime'],$shiftInfo['EndTime'],$registrationDate['StartTime'],$registrationDate['EndTime']);                                                            
                                }
                            } 
                        }
                        else{
                            $Restime10 = 0;
                        } 
                        // caculation WeekdayLateOvertime
                        $WeekdayLateOvertime = 0;
                        // caculation WeekdayOvertime
                        $WeekdayOvertime = 0;
                        // caculation $WeekdayNormalTime
                        $WeekdayNormalTime = ($WeekdayNormalTime02 - $Restime10) +  $addWorkNormalTime['addtime'] + $addWorkNormalTime['downtime'];
                        // WeekendOvertime
                        $WeekendOvertime = 0;
                        // WeekendLateOvertime
                        $WeekendLateOvertime = 0;
                        // HolidayOvertime
                        $HolidayOvertime = 0;
                        // HolidayLateOvertime
                        $HolidayLateOvertime = 0;                                                                                                                                                
                        // Restime 1
                        $ResTime1 = $Restime11 + $Restime10;     
                        // Restime 2
                        $ResTime2 = 0; 
                        // Restime 3
                        $ResTime3 = 0;   
                        // Actual Work Hours
                        $ActualWorkHours = ($WeekdayNormalTime02 - $Restime10 + $addWorkNormalTime['downtime']) + $WeekdayOvertime + $WeekdayLateOvertime + $WeekendOvertime + $WeekendLateOvertime + $HolidayOvertime + $HolidayLateOvertime ;                                                                                  

                    }
                }
                else{
                        // caculation WeekdayLateOvertime
                        $WeekdayLateOvertime = 0;
                        // caculation WeekdayOvertime
                        $WeekdayOvertime = 0;
                        // caculation $WeekdayNormalTime
                        $WeekdayNormalTime = 0;
                        // WeekendOvertime
                        $WeekendOvertime = 0;
                        // WeekendLateOvertime
                        $WeekendLateOvertime = 0;
                        // HolidayOvertime
                        $HolidayOvertime = 0;
                        // HolidayLateOvertime
                        $HolidayLateOvertime = 0;                                                                                                                                                
                        // Restime 1
                        $ResTime1 = 0;     
                        // Restime 2
                        $ResTime2 = 0; 
                        // Restime 3
                        $ResTime3 = 0;                      
                        // Actual WorkHours                        
                        $ActualWorkHours = 0;
                }
            }
            // arrivaltime is empty
            else{
                /* no caculation time working */
                // caculation WeekdayLateOvertime
                $WeekdayLateOvertime = 0;
                // caculation WeekdayOvertime
                $WeekdayOvertime = 0;
                // caculation $WeekdayNormalTime
                $WeekdayNormalTime = 0;
                // WeekendOvertime
                $WeekendOvertime = 0;
                // WeekendLateOvertime
                $WeekendLateOvertime = 0;
                // HolidayOvertime
                $HolidayOvertime = 0;
                // HolidayLateOvertime
                $HolidayLateOvertime = 0;                                                                                                                                                
                // Restime 1
                $ResTime1 = 0;     
                // Restime 2
                $ResTime2 = 0; 
                // Restime 3
                $ResTime3 = 0;                        
                // Actual WorkHours                
                $ActualWorkHours = 0;                                     
            }
            $data = array(
                'ResTime1'                  =>  $ResTime1,
                'ResTime2'                  =>  $ResTime2,
                'ResTime3'                  =>  $ResTime3,
                'WeekdayNormalTime'         =>  $WeekdayNormalTime,
                'WeekdayOvertime'           =>  $WeekdayOvertime,
                'WeekdayLateOvertime'       =>  $WeekdayLateOvertime,
                'WeekendOvertime'           =>  $WeekendOvertime,
                'WeekendLateOvertime'       =>  $WeekendLateOvertime,
                'HolidayOvertime'           =>  $HolidayOvertime,
                'HolidayLateOvertime'       =>  $HolidayLateOvertime,
                'ActualWorkHours'           =>  $ActualWorkHours,                                                                                                                              
            );
            return $data;
        } 
        /*
         * @author :        HungLV
         * @created:        
         * @Description:   Caculation time working normal one day of employee
         * @Input :        variable
         * @Output :       Return array data time working normal
         */ 
        function timeCardWorkingWeekendDay($Arrivaltime,$Leavetime,$Date,$employeeID,$shiftInfo){
            $registrationDates = $this->Mmod_tcmanipulation->getLeaveRegistrationEmployeeID($employeeID,$Date);
            $dayWeekendWorking = date("w", strtotime($Date));
            if($Leavetime!=""){                                       
                if( strtotime($Leavetime) > strtotime($Arrivaltime) ){
                    // date has sunday 
                    if($dayWeekendWorking==0){
                            // check overtime 
                            if($this->Mmod_tcmanipulation->isCheckOvertime($employeeID,$Date))
                            {
                                // caculation late over time
                                $WeekendLateOvertime00 = $this->Mmod_tcmanipulation->weekdayLateOvertime($Arrivaltime,$Leavetime,$shiftInfo['StartNightOvertime']);
                                // caculation overtime
                                $WeekendOvertime01 = $this->Mmod_tcmanipulation->weekdayOvertime($Arrivaltime,$Leavetime,$shiftInfo['EndEveningOvertime'],$shiftInfo['StartEveningOvertime']);
                                // caculation working nomarl time
                                $WeekendNormalTime02 = $this->Mmod_tcmanipulation->weekdayNormalTime($Arrivaltime,$Leavetime,$shiftInfo['EndTime'],$shiftInfo['StartTime'],$shiftInfo['EndRestTime1'],$shiftInfo['StartRestTime1']);
                                if(isset($registrationDates)&& !empty($registrationDates)){
                                    foreach($registrationDates as $registrationDate){
                                        if($this->Mmod_tcmanipulation->isCheckLeaveRegistrationPaid($registrationDate['LeaveTypeId'],$employeeID,$Date)== false){
                                            // caculation resetime 30
                                            $Restime30 = $this->Mmod_tcmanipulation->resTime30($Arrivaltime,$Leavetime,$shiftInfo['StartNightOvertime'],$shiftInfo['EndNightOvertime'],$registrationDate['StartTime'],$registrationDate['StartTime']);
                                            // caculation resetime 20
                                            $Restime20 = $this->Mmod_tcmanipulation->resTime20($Arrivaltime,$Leavetime,$shiftInfo['StartEveningOvertime'],$shiftInfo['EndEveningOvertime'],$registrationDate['StartTime'],$registrationDate['EndTime']);
                                            // caculation resetime 10
                                            $Restime10 = $this->Mmod_tcmanipulation->resTime10($Arrivaltime,$Leavetime,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1'],$shiftInfo['StartTime'],$shiftInfo['EndTime'],$registrationDate['StartTime'],$registrationDate['EndTime']); 
                                        }
                                     }                                                             
                                }
                                else{
                                    $Restime30 = 0;
                                    $Restime20 = 0;
                                    $Restime10 = 0;
                                }
                                // caculation resetime 3 default
                                $Restime31 = $this->Mmod_tcmanipulation->resTime31($Arrivaltime,$Leavetime,$shiftInfo['EndEveningOvertime'],$shiftInfo['StartNightOvertime']);
                                // caculation resetime 2 default
                                $Restime21 = $this->Mmod_tcmanipulation->resTime21($Arrivaltime,$Leavetime,$shiftInfo['EndTime'],$shiftInfo['StartEveningOvertime']);
                                // caculation resetime 1 default
                                $Restime11 = $this->Mmod_tcmanipulation->resTime11($Arrivaltime,$Leavetime,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1']);

                                // caculation WeekdayLateOvertime
                                $WeekdayLateOvertime = 0;
                                // caculation WeekdayOvertime
                                $WeekdayOvertime = 0;
                                // caculation $WeekdayNormalTime 
                                $WeekdayNormalTime = 0;
                                // WeekendOvertime
                                $WeekendOvertime = $WeekendNormalTime02 - $Restime10;
                                // WeekendLateOvertime
                                $WeekendLateOvertime = ($WeekendLateOvertime00 - $Restime30) + ($WeekendOvertime01 - $Restime20);
                                // HolidayOvertime
                                $HolidayOvertime = 0;
                                // HolidayLateOvertime
                                $HolidayLateOvertime = 0;                                                                                                                                                
                                // Restime 1
                                $ResTime1 = $Restime11 + $Restime10;     
                                // Restime 2
                                $ResTime2 = $Restime21 + $Restime20; 
                                // Restime 3
                                $ResTime3 = $Restime31 + $Restime30;
                                // Actual Work Hours
                                $ActualWorkHours = $WeekdayNormalTime + $WeekdayOvertime + $WeekdayLateOvertime + $WeekendOvertime + $WeekendLateOvertime + $HolidayOvertime + $HolidayLateOvertime;                                                                                       

                            }
                            else{
                                $addWorkNormalTime = 0;
                                // caculation working nomarl time
                                $WeekdayNormalTime02 = $this->Mmod_tcmanipulation->weekdayNormalTime($Arrivaltime,$Leavetime,$shiftInfo['EndTime'],$shiftInfo['StartTime'],$shiftInfo['EndRestTime1'],$shiftInfo['StartRestTime1']); 
                                // caculation resetime 1 default
                                $Restime11 = $this->Mmod_tcmanipulation->resTime11($Arrivaltime,$Leavetime,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1']);
                                if(isset($registrationDates)&& !empty($registrationDates)){
                                    // caculation leave registration is Paid
                                    $addWorkNormalTime = $this->Mmod_tcmanipulation->getTimeLeaveRegistrationIsPaid($Arrivaltime,$Leavetime,$registrationDates,$shiftInfo['TotalWorkHours'],$shiftInfo['StartTimeAfternoon'],$employeeID,$Date,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1'],$shiftInfo['EndTime']);
                                    foreach($registrationDates as $registrationDate){
                                        // leave registration un Paid
                                        if($this->Mmod_tcmanipulation->isCheckLeaveRegistrationPaid($registrationDate['LeaveTypeId'],$employeeID,$Date)== false){
                                            // caculation resetime 10
                                            $Restime10 = $this->Mmod_tcmanipulation->resTime10($Arrivaltime,$Leavetime,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1'],$shiftInfo['StartTime'],$shiftInfo['EndTime'],$registrationDate['StartTime'],$registrationDate['EndTime']);                                                            
                                        }
                                    } 
                                }
                                else{
                                    $Restime10 = 0;
                                }
                                // caculation WeekdayLateOvertime
                                $WeekdayLateOvertime = 0;
                                // caculation WeekdayOvertime
                                $WeekdayOvertime = 0;
                                // caculation $WeekdayNormalTime
                                $WeekdayNormalTime = ($WeekdayNormalTime02 - $Restime10) +  $addWorkNormalTime['addtime'] + $addWorkNormalTime['downtime'];
                                // WeekendOvertime
                                $WeekendOvertime = 0;
                                // WeekendLateOvertime
                                $WeekendLateOvertime = 0;
                                // HolidayOvertime
                                $HolidayOvertime = 0;
                                // HolidayLateOvertime
                                $HolidayLateOvertime = 0;                                                                                                                                                
                                // Restime 1
                                $ResTime1 = $Restime11 + $Restime10;     
                                // Restime 2
                                $ResTime2 = 0; 
                                // Restime 3
                                $ResTime3 = 0;
                                // Actual Work Hours
                                $ActualWorkHours = ($WeekdayNormalTime02 - $Restime10 + $addWorkNormalTime['downtime']) + $WeekdayOvertime + $WeekdayLateOvertime + $WeekendOvertime + $WeekendLateOvertime + $HolidayOvertime + $HolidayLateOvertime ;                                                                                  

                            }                     
                    }
                    // date is Saturday
                    else{
                        // case 1 have working weekend: Half Day Time normal other overtime
                        if($shiftInfo['HalfDayOnWeekend']==1){
                                $RestimeWeekend11 = 0;
                            // case 1: register overtime
                                // check overtime 
                                if($this->Mmod_tcmanipulation->isCheckOvertime($employeeID,$Date))
                                {
                                    // caculation late over time
                                    $WeekendLateOvertime00 = $this->Mmod_tcmanipulation->weekdayLateOvertime($Arrivaltime,$Leavetime,$shiftInfo['StartNightOvertime']);
                                    // caculation overtime
                                    $WeekendOvertime01 = $this->Mmod_tcmanipulation->weekdayOvertime($Arrivaltime,$Leavetime,$shiftInfo['EndEveningOvertime'],$shiftInfo['StartEveningOvertime']);
                                    // caculation overtime weekend start HalfDayEndTime
                                    $HHalf_Day_End_Time = date('H', strtotime($shiftInfo['HalfDayEndTime'])) + 1;
                                    $MHalf_Day_End_Time = date('i', strtotime($shiftInfo['HalfDayEndTime']));
                                    $Half_Day_End_Time = $HHalf_Day_End_Time.":".$MHalf_Day_End_Time.":00";                                
                                    $WeekendOvertime04 = $this->Mmod_tcmanipulation->weekdayOvertime($Arrivaltime,$Leavetime,$shiftInfo['EndTime'],$Half_Day_End_Time);                                                
                                    // caculation working nomarl time
                                    $WeekendNormalTime02 = $this->Mmod_tcmanipulation->weekdayNormalTime($Arrivaltime,$Leavetime,$shiftInfo['EndTime'],$shiftInfo['StartTime'],$shiftInfo['EndRestTime1'],$shiftInfo['StartRestTime1']);
                                    if(isset($registrationDates)&& !empty($registrationDates)){
                                        foreach($registrationDates as $registrationDate){
                                            if($this->Mmod_tcmanipulation->isCheckLeaveRegistrationPaid($registrationDate['LeaveTypeId'],$employeeID,$Date)== false){
                                                // caculation resetime 30
                                                $Restime30 = $this->Mmod_tcmanipulation->resTime30($Arrivaltime,$Leavetime,$shiftInfo['StartNightOvertime'],$shiftInfo['EndNightOvertime'],$registrationDate['StartTime'],$registrationDate['EndTime']);
                                                // caculation resetime 20
                                                $Restime20 = $this->Mmod_tcmanipulation->resTime20($Arrivaltime,$Leavetime,$shiftInfo['StartEveningOvertime'],$shiftInfo['EndEveningOvertime'],$registrationDate['StartTime'],$registrationDate['EndTime']);
                                                // caculation resetime 40 overtime weekend start HalfDayEndTime
                                                $Restime40 = $this->Mmod_tcmanipulation->resTime20($Arrivaltime,$Leavetime,$Half_Day_End_Time,$shiftInfo['EndTime'],$registrationDate['StartTime'],$registrationDate['EndTime']);                                                                                                        
                                                // caculation resetime 10
                                                $RestimeWeekendNormal = $this->Mmod_tcmanipulation->resTimeWeekend11($Arrivaltime,$Leavetime,$shiftInfo['HalfDayStartTime'],$shiftInfo['HalfDayEndTime'],$registrationDate['StartTime'],$registrationDate['EndTime']);                                                                
                                            }
                                        }                                                                                                                 
                                    }
                                    else{
                                        $Restime30 = 0;
                                        $Restime20 = 0;
                                        $Restime40 = 0;
                                    }
                                    // caculation resetime 3 default
                                    $Restime31 = $this->Mmod_tcmanipulation->resTime31($Arrivaltime,$Leavetime,$shiftInfo['EndEveningOvertime'],$shiftInfo['StartNightOvertime']);
                                    // caculation resetime 2 default
                                    $Restime21 = $this->Mmod_tcmanipulation->resTime21($Arrivaltime,$Leavetime,$shiftInfo['EndTime'],$shiftInfo['StartEveningOvertime']);
                                    // caculation resetime 4 default overtime weekend start HalfDayEndTime
                                    $Restime41 = $this->Mmod_tcmanipulation->resTime21($Arrivaltime,$Leavetime,$shiftInfo['HalfDayEndTime'],$Half_Day_End_Time);                                                
                                    // caculation resetime 1 default
                                    //$Restime11 = $this->resTime11($ArrivaltimeWeekend,$Leavetime,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1']);

                                    // caculation WeekdayLateOvertime
                                    $WeekdayLateOvertime = 0;
                                    // caculation WeekdayOvertime
                                    $WeekdayOvertime = 0;
                                    // caculation $WeekdayNormalTime 
                                    $WeekdayNormalTime = $WeekendNormalTime02 - $RestimeWeekendNormal;
                                    // WeekendOvertime
                                    $WeekendOvertime = ($WeekendOvertime04 - $Restime40) + ($WeekendOvertime01 - $Restime20);
                                    // WeekendLateOvertime
                                    $WeekendLateOvertime = $WeekendLateOvertime00 - $Restime30;
                                    // HolidayOvertime
                                    $HolidayOvertime = 0;
                                    // HolidayLateOvertime
                                    $HolidayLateOvertime = 0;                                                                                                                                                
                                    // Restime 1
                                    $ResTime1 = $RestimeWeekendNormal;     
                                    // Restime 2
                                    $ResTime2 = $Restime41 + $Restime40 + $Restime20 + $Restime21; 
                                    // Restime 3
                                    $ResTime3 = $Restime31 + $Restime30;
                                    // Actual Work Hours
                                    $ActualWorkHours = $WeekdayNormalTime + $WeekdayOvertime + $WeekdayLateOvertime + $WeekendOvertime + $WeekendLateOvertime + $HolidayOvertime + $HolidayLateOvertime;                                                                                                                                                                                                                                                                                                 
                                }
                                 // case 2: dont register overtime = weekday normal
                                else{
                                    // caculation working nomarl time
                                    $WeekendNormalTime02 = $this->Mmod_tcmanipulation->weekendHalfDayNormalTime($Arrivaltime,$Leavetime,$shiftInfo['HalfDayStartTime'],$shiftInfo['HalfDayEndTime']); 
                                    // caculation resetime weekend
                                    if(isset($registrationDates)&& !empty($registrationDates)){
                                        foreach($registrationDates as $registrationDate){
                                            if($this->Mmod_tcmanipulation->isCheckLeaveRegistrationPaid($registrationDate['LeaveTypeId'],$employeeID,$Date)== false){
                                                // caculation resetime
                                                $RestimeWeekend11 = $this->Mmod_tcmanipulation->resTimeWeekend11($Arrivaltime,$Leavetime,$shiftInfo['HalfDayStartTime'],$shiftInfo['HalfDayEndTime'],$registrationDate['StartTime'],$registrationDate['EndTime']);
                                            }                                                                
                                        }

                                    }
                                    // caculation WeekdayLateOvertime
                                    $WeekdayLateOvertime = 0;
                                    // caculation WeekdayOvertime
                                    $WeekdayOvertime = 0;
                                    // caculation $WeekdayNormalTime
                                    $WeekdayNormalTime = $WeekendNormalTime02 - $RestimeWeekend11;
                                    // WeekendOvertime
                                    $WeekendOvertime = 0;
                                    // WeekendLateOvertime
                                    $WeekendLateOvertime = 0;
                                    // HolidayOvertime
                                    $HolidayOvertime = 0;
                                    // HolidayLateOvertime
                                    $HolidayLateOvertime = 0;                                                                                                                                                
                                    // Restime 1
                                    $ResTime1 = $RestimeWeekend11;     
                                    // Restime 2
                                    $ResTime2 = 0; 
                                    // Restime 3
                                    $ResTime3 = 0;                              
                                    // Actual work hours
                                    $ActualWorkHours = $WeekdayNormalTime + $WeekdayOvertime + $WeekdayLateOvertime + $WeekendOvertime + $WeekendLateOvertime + $HolidayOvertime + $HolidayLateOvertime;                                                                                       														

                                }                                                           
                        }
                        // case 2 dont working weekend
                        else{
                            // case 21: register overtime
                                // check overtime 
                                if($this->Mmod_tcmanipulation->isCheckOvertime($employeeID,$Date))
                                {
                                    // caculation late over time
                                    $WeekendLateOvertime00 = $this->Mmod_tcmanipulation->weekdayLateOvertime($Arrivaltime,$Leavetime,$shiftInfo['StartNightOvertime']);
                                    // caculation overtime
                                    $WeekendOvertime01 = $this->Mmod_tcmanipulation->weekdayOvertime($Arrivaltime,$Leavetime,$shiftInfo['EndEveningOvertime'],$shiftInfo['StartEveningOvertime']);
                                    // caculation working nomarl time
                                    $WeekendNormalTime02 = $this->Mmod_tcmanipulation->weekdayNormalTime($Arrivaltime,$Leavetime,$shiftInfo['EndTime'],$shiftInfo['StartTime'],$shiftInfo['EndRestTime1'],$shiftInfo['StartRestTime1']);
                                    if(isset($registrationDates)&& !empty($registrationDates)){
                                        foreach($registrationDates as $registrationDate){
                                            if($this->Mmod_tcmanipulation->isCheckLeaveRegistrationPaid($registrationDate['LeaveTypeId'],$employeeID,$Date)== false){
                                                // caculation resetime 30
                                                $Restime30 = $this->Mmod_tcmanipulation->resTime30($Arrivaltime,$Leavetime,$shiftInfo['StartNightOvertime'],$shiftInfo['EndNightOvertime'],$registrationDate['StartTime'],$registrationDate['StartTime']);
                                                // caculation resetime 20
                                                $Restime20 = $this->Mmod_tcmanipulation->resTime20($Arrivaltime,$Leavetime,$shiftInfo['StartEveningOvertime'],$shiftInfo['EndEveningOvertime'],$registrationDate['StartTime'],$registrationDate['EndTime']);
                                                // caculation resetime 10
                                                $Restime10 = $this->Mmod_tcmanipulation->resTime10($Arrivaltime,$Leavetime,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1'],$shiftInfo['StartTime'],$shiftInfo['EndTime'],$registrationDate['StartTime'],$registrationDate['EndTime']); 
                                            }
                                         }                                                             
                                    }
                                    else{
                                        $Restime30 = 0;
                                        $Restime20 = 0;
                                        $Restime10 = 0;
                                    }
                                    // caculation resetime 3 default
                                    $Restime31 = $this->Mmod_tcmanipulation->resTime31($Arrivaltime,$Leavetime,$shiftInfo['EndEveningOvertime'],$shiftInfo['StartNightOvertime']);
                                    // caculation resetime 2 default
                                    $Restime21 = $this->Mmod_tcmanipulation->resTime21($Arrivaltime,$Leavetime,$shiftInfo['EndTime'],$shiftInfo['StartEveningOvertime']);
                                    // caculation resetime 1 default
                                    $Restime11 = $this->Mmod_tcmanipulation->resTime11($Arrivaltime,$Leavetime,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1']);

                                    // caculation WeekdayLateOvertime
                                    $WeekdayLateOvertime = 0;
                                    // caculation WeekdayOvertime
                                    $WeekdayOvertime = 0;
                                    // caculation $WeekdayNormalTime 
                                    $WeekdayNormalTime = 0;
                                    // WeekendOvertime
                                    $WeekendOvertime = $WeekendNormalTime02 - $Restime10;
                                    // WeekendLateOvertime
                                    $WeekendLateOvertime = ($WeekendLateOvertime00 - $Restime30) + ($WeekendOvertime01 - $Restime20);
                                    // HolidayOvertime
                                    $HolidayOvertime = 0;
                                    // HolidayLateOvertime
                                    $HolidayLateOvertime = 0;                                                                                                                                                
                                    // Restime 1
                                    $ResTime1 = $Restime11 + $Restime10;     
                                    // Restime 2
                                    $ResTime2 = $Restime21 + $Restime20; 
                                    // Restime 3
                                    $ResTime3 = $Restime31 + $Restime30;                                
                                    // Actual Work Hours
                                    $ActualWorkHours = $WeekdayNormalTime + $WeekdayOvertime + $WeekdayLateOvertime + $WeekendOvertime + $WeekendLateOvertime + $HolidayOvertime + $HolidayLateOvertime;                                                                                       

                                }
                                 // case 22: dont register overtime = weekday normal
                                else{
                                    $addWorkNormalTime = 0;
                                    // caculation working nomarl time
                                    $WeekdayNormalTime02 = $this->Mmod_tcmanipulation->weekdayNormalTime($Arrivaltime,$Leavetime,$shiftInfo['EndTime'],$shiftInfo['StartTime'],$shiftInfo['EndRestTime1'],$shiftInfo['StartRestTime1']); 
                                    // caculation resetime 1 default
                                    $Restime11 = $this->Mmod_tcmanipulation->resTime11($Arrivaltime,$Leavetime,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1']);
                                    if(isset($registrationDates)&& !empty($registrationDates)){
                                        foreach($registrationDates as $registrationDate){
                                            // case 1 leave registration is Paid
                                            $addWorkNormalTime = $this->Mmod_tcmanipulation->getTimeLeaveRegistrationIsPaid($Arrivaltime,$Leavetime,$registrationDates,$shiftInfo['TotalWorkHours'],$shiftInfo['StartTimeAfternoon'],$employeeID,$Date,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1'],$shiftInfo['EndTime']);
                                            if($this->Mmod_tcmanipulation->isCheckLeaveRegistrationPaid($registrationDate['LeaveTypeId'],$employeeID,$Date)== false){
                                            // case 2 leave registration un Paid
                                                // caculation resetime 10
                                                $Restime10 = $this->Mmod_tcmanipulation->resTime10($Arrivaltime,$Leavetime,$shiftInfo['StartRestTime1'],$shiftInfo['EndRestTime1'],$shiftInfo['StartTime'],$shiftInfo['EndTime'],$registrationDate['StartTime'],$registrationDate['EndTime']);                                                                    
                                            }
                                        }                                                             
                                    }
                                    else{
                                        $Restime10 = 0;
                                    } 
                                    // caculation WeekdayLateOvertime
                                    $WeekdayLateOvertime = 0;
                                    // caculation WeekdayOvertime
                                    $WeekdayOvertime = 0;
                                    // caculation $WeekdayNormalTime
                                    $WeekdayNormalTime = ($WeekdayNormalTime02 - $Restime10) + $addWorkNormalTime['addtime'] + $addWorkNormalTime['downtime'];
                                    // WeekendOvertime
                                    $WeekendOvertime = 0;
                                    // WeekendLateOvertime
                                    $WeekendLateOvertime = 0;
                                    // HolidayOvertime
                                    $HolidayOvertime = 0;
                                    // HolidayLateOvertime
                                    $HolidayLateOvertime = 0;                                                                                                                                                
                                    // Restime 1
                                    $ResTime1 = $Restime11 + $Restime10;     
                                    // Restime 2
                                    $ResTime2 = 0; 
                                    // Restime 3
                                    $ResTime3 = 0;
                                    // Actual Work Hours
                                    $ActualWorkHours = ($WeekdayNormalTime02 - $Restime10 + $addWorkNormalTime['downtime']) + $WeekdayOvertime + $WeekdayLateOvertime + $WeekendOvertime + $WeekendLateOvertime + $HolidayOvertime + $HolidayLateOvertime;                                                                                       

                                }                                        

                            }
                        }
                    }
                    else{
                            // caculation WeekdayLateOvertime
                            $WeekdayLateOvertime = 0;
                            // caculation WeekdayOvertime
                            $WeekdayOvertime = 0;
                            // caculation $WeekdayNormalTime
                            $WeekdayNormalTime = 0;
                            // WeekendOvertime
                            $WeekendOvertime = 0;
                            // WeekendLateOvertime
                            $WeekendLateOvertime = 0;
                            // HolidayOvertime
                            $HolidayOvertime = 0;
                            // HolidayLateOvertime
                            $HolidayLateOvertime = 0;                                                                                                                                                
                            // Restime 1
                            $ResTime1 = 0;     
                            // Restime 2
                            $ResTime2 = 0; 
                            // Restime 3
                            $ResTime3 = 0;
                            // leave time 
                            $LeaveTimeIsPaid = 0;                      
                            // Actual WorkHours                            
                            $ActualWorkHours = 0;
                    }
               }
            else{
                    $Leavetime = $Arrivaltime;
                    // caculation WeekdayLateOvertime
                    $WeekdayLateOvertime = 0;
                    // caculation WeekdayOvertime
                    $WeekdayOvertime = 0;
                    // caculation $WeekdayNormalTime
                    $WeekdayNormalTime = 0;
                    // WeekendOvertime
                    $WeekendOvertime = 0;
                    // WeekendLateOvertime
                    $WeekendLateOvertime = 0;
                    // HolidayOvertime
                    $HolidayOvertime = 0;
                    // HolidayLateOvertime
                    $HolidayLateOvertime = 0;                                                                                                                                                
                    // Restime 1
                    $ResTime1 = 0;     
                    // Restime 2
                    $ResTime2 = 0; 
                    // Restime 3
                    $ResTime3 = 0;                       
                    // Actual WorkHours                    
                    $ActualWorkHours = 0;
            }
            $data = array(
                'ResTime1'                  =>  $ResTime1,
                'ResTime2'                  =>  $ResTime2,
                'ResTime3'                  =>  $ResTime3,
                'WeekdayNormalTime'         =>  $WeekdayNormalTime,
                'WeekdayOvertime'           =>  $WeekdayOvertime,
                'WeekdayLateOvertime'       =>  $WeekdayLateOvertime,
                'WeekendOvertime'           =>  $WeekendOvertime,
                'WeekendLateOvertime'       =>  $WeekendLateOvertime,
                'HolidayOvertime'           =>  $HolidayOvertime,
                'HolidayLateOvertime'       =>  $HolidayLateOvertime,
                'ActualWorkHours'           =>  $ActualWorkHours,                                                                                                                              
            );
             return $data;
        }
        /*
         * @author :        HungLV
         * @created:        
         * @Description:   check exist employess timecard
         * @Input :        $id_employee
         * @Output :       Return true or false
         */
        function checkExistEmployee($id=0){
            if(is_numeric($id)&&$id!=0){
                $this->db->where('EmployeeId',$id);
                $query = $this->db->get($this->table_name);
                if($query->num_rows() > 0){
                    return TRUE;
                }
                else{
                    return FALSE;
                }
            }
            else{
                return FALSE;
            }
        }
        /*
         * @author :        HungLV
         * @created:        
         * @Description:   get shift info by time card id
         * @Input :        (Int) $id
         * @Output :       Return array data
         */
        function getShiftInfo(){
            $this->db->from($this->table_shiftinfo);
            $this->db->where('CompanyCode',$this->session->userdata('CompanyCode'));
            $this->db->order_by("ShiftId", "ASC"); 
            $query = $this->db->get();
            return $query->result_array();
        }
}
?>
